//实现下滑
$.fn.slideDown = function(duration) {
    var height = this.height();

    this.css("visibility", "visible");
    this.css("height", 0);
    this.animate({
        height: height
    }, duration);
};

$(function() {
	var deviceId = $("#deviceId").val();//设备ID
	var remark = parseInt($("#remark").val());//奖品等级数字
	var status = $("#status").val();//兑奖状态
	var phone = $("#phone").val();//中奖码
	var first = $("#first").val();//抽奖次数
	var statusContainer = $("#statusContainer");//状态容器
	var statusWrap = $("#statusWrap");
	var statusContent = $("#statusContent");//状态内容
	var htmlStr = '';

	//添加中奖信息
	var winHtml = function(gift){
		statusContainer.addClass("status-text__win").removeClass("status-text__won");
		htmlStr = '<p>恭喜您获得</p>'
	          	 +'<p id="giftName">'+gift+'</p>'
	          	 +'<p class="winning-code">您的中奖码为"<span id="winCode">'+phone+'</span>"</p>'
	          	 //+'<a class="share-btn" id="shareBtn" href="share"></a>'
	          	 ;
		statusContent.html(htmlStr);
	}

	//遮罩层
	$("html, body").css("overflow", "hidden");
	$("body").on("touchmove", function (e){
	    e.preventDefault();
	});

	switch (remark){
	    case 1:
	    	winHtml("亨吉利定制金怀表");
	        break;
	    case 2:
	        winHtml("亨吉利商务套餐");
	        break;
/*	    case 3:
			winHtml("“甜蜜蜜现场饼干烘焙”8折券");
	        break;
	    case 4:
			winHtml("“武汉公园客”明信片5折券");
	        break;
	    case 5:
			winHtml("创意食盘8折券");
	        break;
	    case 6:
			winHtml("文艺帆布包8折券");
	        break;
	    case 7:
			winHtml("康师傅糕饼一包");
	        break;*/
	    default:
	    	//
	    	if(first == 1){
	    		statusContainer.addClass("status-text__wished").removeClass("status-text__wish");
	    		statusWrap.removeClass("status-wrap").addClass("status-wrap--sm");
	    		statusContent.html("");
	    	}
	    	else{
	    		statusContainer.addClass("status-text__wish").removeClass("status-text__wished");
	        	//htmlStr = '<a class="share-btn" id="shareBtn" href="share"></a>';
	        	//statusContent.html(htmlStr);
	        	statusContent.html("");
	    	}
	        break;
	}

	if(status == 1){
		statusContent.html("");
		statusContainer.addClass("status-text__received").removeClass("status-text__win");
	}
	if(status == 2){
		statusContainer.addClass("status-text__won").removeClass("status-text__win");
		statusWrap.removeClass("status-wrap").addClass("status-wrap--sm");
		htmlStr = '<p>您已中奖</p>'
	          	 +'<p>您的中奖码为"<span id="winCode">'+phone+'</span>"</p>'
	          	 +'<p>择日去领吧！</p>';
        statusContent.html(htmlStr);
	}

	$("#mask").slideDown("slow");
});